export default class CZML {
  constructor(basicCesium) {
    this.basicCesium = basicCesium
    this.viewer = basicCesium.viewer;
    this.entities = this.viewer.entities;

    this.initVehicle()
    this.initSatellites()
  }

  initSatellites() {
    if (this.viewer.dataSources.length > 0) {
      this.clearAll();
    }
    this.viewer.dataSources.add(
      Cesium.CzmlDataSource.load("./media/simple.czml")
    );
  }

  initVehicle() {
    if (this.viewer.dataSources.length > 0) {
      this.clearAll();
    }
    Cesium.CzmlDataSource.load("./media/Vehicle.czml").then(dataSource => {
      this.viewer.dataSources.add(dataSource).then(res => {
        this.viewer.zoomTo(res.entities.values)
        // console.log(res.entities.getById('Vehicle'))
      });
    });
  }

  clearAll() {
    this.viewer.dataSources.removeAll();
  }
}